"""
Steam交易状态刷新接口数据模型
"""
from dataclasses import dataclass, field, asdict
from typing import Dict, Any, Optional

@dataclass
class SteamTradeStatusRefreshRequest:
    """Steam交易状态刷新请求"""
    Sessionid: str

    def to_dict(self) -> Dict[str, Any]:
        """转换为字典格式
        
        Returns:
            Dict[str, Any]: 字典格式的数据
        """
        return {
            "Sessionid": self.Sessionid
        }

@dataclass
class SteamTradeStatusRefreshData:
    """Steam交易状态刷新数据"""
    userId: int
    steamTradeStatus: int
    expireTime: Optional[str] = None
    steamTradeStatusTip: str = ""
    steamJumpUrl: str = ""
    tradeStatusRefreshTimeTip: str = ""

@dataclass
class SteamTradeStatusRefreshResponse:
    """Steam交易状态刷新响应"""
    code: int
    msg: str
    timestamp: int
    data: Optional[SteamTradeStatusRefreshData] = None

    @classmethod
    def from_dict(cls, data: Dict[str, Any]) -> 'SteamTradeStatusRefreshResponse':
        """从字典创建响应对象
        
        Args:
            data: 响应数据字典
            
        Returns:
            SteamTradeStatusRefreshResponse: 响应对象
        """
        response_data = None
        if data.get('data'):
            response_data = SteamTradeStatusRefreshData(
                userId=data['data'].get('userId'),
                steamTradeStatus=data['data'].get('steamTradeStatus'),
                expireTime=data['data'].get('expireTime'),
                steamTradeStatusTip=data['data'].get('steamTradeStatusTip', ''),
                steamJumpUrl=data['data'].get('steamJumpUrl', ''),
                tradeStatusRefreshTimeTip=data['data'].get('tradeStatusRefreshTimeTip', '')
            )
            
        return cls(
            code=data.get('code'),
            msg=data.get('msg', ''),
            timestamp=data.get('timestamp'),
            data=response_data
        )
